<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=oyva8hEbGyySeHenlvpaPYgbblTWU2mA"></script>
    <title>单个地址解析</title>
    <style>
      body,html{
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
      }
      #container{
        width: 100%;
        height: 100%;
        overflow: hidden;
      }
      #result{
        position: fixed;
        top: 10px;
        left: 10px;
        width: 250px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        background: #fff;
        box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
        border-radius: 7px;
        z-index: 99;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <div id="result">深圳市宝安区西部硅谷</div>
    <script>
      var map = new BMapGL.Map('container');
      map.centerAndZoom(new BMapGL.Point(116.331398,39.897445), 12);
      map.enableScrollWheelZoom(true);

      //创建地址解析器实例
      var myGeo = new BMapGL.Geocoder();
      // 将地址解析结果显示在地图上，并调整地图视野
      myGeo.getPoint('深圳市宝安区西部硅谷', function(point){
        if(point){
          map.centerAndZoom(point, 16);
          map.addOverlay(new BMapGL.Marker(point, {title: '深圳市宝安区西部硅谷'}))
        }else{
          alert('您选择的地址没有解析到结果！');
        }
      })
    </script>
  </body>
</html>
